package offer;

import java.util.Stack;

/*
* P51 面试题5：从尾到头打印
*
* */
public class PrintLinkReverse {

    public static void printLinkReverse(ListNode head){
        if(head == null){
            return;
        }
        Stack<ListNode> stack = new Stack<>();
        ListNode node = head;
        while(node != null){

            stack.push(node);
            node = node.next;
        }
        while(!stack.isEmpty()){
            node = stack.pop();
            System.out.println(node.value);
        }

    }
}
